package arrays;

/**
 * @author LiangMu
 * @version \$Id: P7.java, v 0.1, 2022年12月10日 11:26 LiangMu Exp $$
 */
public class P7 {
    public static void main(String[] args) {
        int[] nums = new int[]{1, 2, 3, 4, 5, 6, 7};
        rotate(nums, 3);
        System.out.println(nums);

    }

    public static void rotate(int[] nums, int k) {
        int len = nums.length;
        k %= len;
        reverse(nums, 0, len - 1);
        reverse(nums, 0, k - 1);
        reverse(nums, k, len - 1);

    }

    public static void reverse(int[] nums, int start, int end) {
        while (start < end) {
            int temp = nums[start];
            nums[start++] = nums[end];
            nums[end--] = temp;
        }
    }

    public static int fun(int n) {
        return n > 3 ? fun(n - 1) + fun(n - 2) + fun(n - 3) : 1;
    }
}
